//
//  GMPackageFirCell.m
//  Teecloud
//
//  Created by 小熊 on 2018/10/29.
//  Copyright © 2018年 小志. All rights reserved.
//

#import "GMPackageFirCell.h"
#import "ZJTimeCountDown.h"
@interface GMPackageFirCell()
@property (weak, nonatomic) IBOutlet UILabel *titleName;
@property (weak, nonatomic) IBOutlet UIButton *biaoqian;
@property (weak, nonatomic) IBOutlet UILabel *leftLab;
@property (weak, nonatomic) IBOutlet UILabel *rightLab;

@end
@implementation GMPackageFirCell
- (void)awakeFromNib {
    [super awakeFromNib];
    self.biaoqian.layer.borderWidth =1.0;
    self.biaoqian.layer.borderColor =[UIColor colorWithHexString:@"FF8D00"].CGColor;
    self.biaoqian.layer.cornerRadius=5;
}
-(void)setModel:(GMMyclassModel *)model{
    _model = model;
    self.titleName.text = model.Name;
    [self.biaoqian setTitle:[NSString stringWithFormat:@"  %@  ",model.ResTypeName] forState:UIControlStateNormal];
    self.leftLab.text = model.FromName;
    if ([model.ResType isEqualToNumber:@(1)]) {
        /**视频*/
        NSString *perStr = [NSString stringWithFormat:@"%@%%",model.Percent];
        NSString *desStr = [NSString stringWithFormat:@"%@分钟  %@",model.TimeLen,perStr];
        self.rightLab.attributedText = [NSMutableAttributedString String:desStr RangeString:perStr];
    }else if ([model.ResType isEqualToNumber:@(2)]){
        /**文档*/
        NSString *perStr = [NSString stringWithFormat:@"%@%%",model.Percent];
        NSString *desStr = [NSString stringWithFormat:@"%@页  %@",model.PageCount,perStr];
        self.rightLab.attributedText = [NSMutableAttributedString String:desStr RangeString:perStr];
    }else if ([model.ResType isEqualToNumber:@(3)]){
        /**习题*/
        NSString *perStr = [NSString stringWithFormat:@"%@%%",model.Percent];
        NSString *desStr = [NSString stringWithFormat:@"%@题  %@",model.ExerCount,perStr];
        self.rightLab.attributedText = [NSMutableAttributedString String:desStr RangeString:perStr];
    }else if ([model.ResType isEqualToNumber:@(4)]){
        /**试卷*/
        NSString *desStr = [NSString stringWithFormat:@"测试%@次  平均%@分",model.Count,model.Score];
        self.rightLab.attributedText = [NSMutableAttributedString String:desStr RangeString:[NSString stringWithFormat:@"%@",model.Score]];
    }else if ([model.ResType isEqualToNumber:@(5)]){
        /**考试*/
        if ([model.TestStatus isEqualToNumber:@(0)]) {
            [[ZJTimeCountDown alloc] zj_timeCountDownWithSecondTime:model.SpaceTime completeBlock:^(NSInteger hour, NSInteger minute, NSInteger second) {
                self.rightLab.text = [NSString stringWithFormat:@"距离开考:%ld:%ld:%ld",hour,minute,second];
            }];
        }else if ([model.TestStatus isEqualToNumber:@(1)]){
            self.rightLab.text = @"进入考试";
        }else if ([model.TestStatus isEqualToNumber:@(2)]){
             self.rightLab.text = @"继续考试";
        }else if ([model.TestStatus isEqualToNumber:@(3)]){
             self.rightLab.text = @"停止入场";
        }else{
            if (model.PassMode == -1) {
                self.rightLab.text = @"缺考";
            }else if (model.PassMode == 0){
                self.rightLab.text = [NSString stringWithFormat:@"%@分,未通过",model.Score];
            }else{
                self.rightLab.text = [NSString stringWithFormat:@"%@分,通过",model.Score];
            }
        }
       
    }else if ([model.ResType isEqualToNumber:@(9)]){
        /**课程包*/
        self.rightLab.text = [NSString stringWithFormat:@"%@资源",model.PageCount];
    }
}
@end
